package com.sansan.qiangji.service.impl.device;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sansan.qiangji.entity.device.StackerParam;
import com.sansan.qiangji.form.device.stackerParam.StackerParamListForm;
import com.sansan.qiangji.mapper.device.StackerParamMapper;
import com.sansan.qiangji.service.inter.device.StackerParamService;
import com.sansan.qiangji.utils.pageUtils.PageResult;
import com.sansan.qiangji.utils.pageUtils.PageUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class StackerParamServiceImpl implements StackerParamService {
    private StackerParamMapper stackerParamMapper;

    @Resource
    public void setStackerParamMapper(StackerParamMapper stackerParamMapper){
        this.stackerParamMapper = stackerParamMapper;
    }

    @Override
    public PageResult<StackerParam> stackerParamList(StackerParamListForm stackerParamListForm) {
        int pageNum = stackerParamListForm.getPageNum();
        int pageSize = stackerParamListForm.getPageSize();
        PageHelper.startPage(pageNum, pageSize);
        StackerParam stackerParam = new StackerParam();
        stackerParam.setStackerParamName(stackerParamListForm.getStackerParamName());
        stackerParam.setStackerParamAddress(stackerParamListForm.getStackerParamAddress());
        List<StackerParam> stackerParams = stackerParamMapper.stackerParamList(stackerParam);
        return PageUtil.getPageResult(new PageInfo<>(stackerParams));
    }

    @Override
    public List<StackerParam> findAll() {
        return stackerParamMapper.findAll();
    }

    @Override
    public StackerParam findById(Integer stackerParamId) {
        return stackerParamMapper.findById(stackerParamId);
    }

    @Override
    public List<StackerParam> findStackerParamName(String stackerParamName) {
        return stackerParamMapper.findStackerParamName(stackerParamName);
    }

    @Override
    public int addStackerParam(StackerParam stackerParam) {
        return stackerParamMapper.addStackerParam(stackerParam);
    }

    @Override
    public int updateStackerParam(StackerParam stackerParam) {
        return stackerParamMapper.updateStackerParam(stackerParam);
    }

    @Override
    public int deleteById(Integer stackerParamId) {
        return stackerParamMapper.deleteById(stackerParamId);
    }
}
